import SparkMD5 from "spark-md5";

// 校验图片MD5值唯一性
export function imgMDfive(file) {
    return new Promise((resolve) => {
        var fileReader = new FileReader();
        //此处打印file可看到file下的raw为文件属性
        var dataFile = file.raw;
        let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice
        console.log('blobSlice', blobSlice)
        var spark = new SparkMD5.ArrayBuffer();
        //获取文件二进制数据
        fileReader.readAsArrayBuffer(dataFile)
            //异步执行函数
        fileReader.onload = function(e) {
            spark.append(e.target.result);
            var md5 = spark.end()
            resolve(md5);
        }
    })
}